#include "circle.h"

void CirclePoint(int xc, int yc, int x, int y, COLORREF Color, DIRECTION dir)
{
	switch (dir)
	{
	case DIRECTION::RD:
		putpixel(xc + x, yc + y, Color);
		putpixel(xc + y, yc + x, Color);
		break;
	case DIRECTION::LD:
		putpixel(xc - x, yc + y, Color);
		putpixel(xc - y, yc + x, Color);
		break;
	case DIRECTION::LU:
		putpixel(xc - x, yc - y, Color);
		putpixel(xc - y, yc - x, Color);
		break;
	case DIRECTION::RU:
		putpixel(xc + x, yc - y, Color);
		putpixel(xc + y, yc - x, Color);
		break;
	}
}
void MD_Circle(int xc, int yc, int r, COLORREF Color, DIRECTION dir)
{
	int x = 0, y = r;
	int d = 1 - r;
	CirclePoint(xc, yc, x, y, Color, dir);
	while (x < y)
	{
		if (d < 0)
		{
			d += 2 * x + 3;
		}
		else
		{
			d += (x - y) * 2 + 5;
			--y;
		}
		++x;
		CirclePoint(xc, yc, x, y, Color, dir);
	}
}
